/*
 * 版权所有(c)  1952110078@qq.com  2022 - 2022
 */

package com.ldc.module_login.viewmodel;

import androidx.lifecycle.MutableLiveData;

import com.google.gson.JsonObject;
import com.ldc.commonlibs.common.ViewModelBase;
import com.ldc.commonlibs.http.NetCallback;
import com.ldc.module_login.net.HttpService;

/**
 * @author liudc
 * @since 2022/7/5 22:40
 */
public class LoginViewModel extends ViewModelBase {
    private final MutableLiveData<JsonObject> _loginData = new MutableLiveData<>();

    public MutableLiveData<JsonObject> getLoginData() {
        return _loginData;
    }

    public void login(String phone, String password) {
        getNetDataSource(getServer(HttpService.class)
                .CellPhone(phone, password), new NetCallback<JsonObject>() {
            @Override
            public void onReceiver(JsonObject data) {
                _loginData.setValue(data);
            }

            @Override
            public void onBadReceiver(Throwable throwable) {
                _loginData.setValue(null);
            }
        });

    }
}
